	# 
	#  Syscall multiplexer
	#
	
.section .text

	
.global do_syscall
do_syscall:
	pushl	%ebp
	movl	%esp,%ebp

	# save registers
	# do not save EAX, cause it's the return value
	pushl	%ebx
	pushl	%ecx
	pushl	%edx	
	pushl	%esi
	pushl	%edi		

	# Function number
	movl	0x8(%ebp),%eax
	# Param 1
	movl	0xc(%ebp),%ebx
	# Param 2
	movl	0x10(%ebp),%ecx
	# Param 3
	movl	0x14(%ebp),%edx
	# Param 4
	movl	0x18(%ebp),%esi
	# Param 5
	movl	0x1c(%ebp),%edi

	# Trap into Kernel to do the syscall
	int	$0x20

	# restore registers
	# do not restore EAX, because it's the return value
	popl	%edi
	popl	%esi
	popl	%edx	
	popl	%ecx	
	popl	%ebx				

	popl	%ebp
	ret

